<template>
	<view id="app">
		<view class="container fdc">
			<view class="mb50 bgw" v-for="(item,index) in list" :key="index">
				<view class="w100p mb10 item-top">
					<image :src="item.thumb"></image>
				</view>
				<view class="df aic">
					<view class="f1 f30 fw4  t2hd ">{{item.title}}</view>
					<view class="ml15 w130 bd1s brc9 c666 f26 tac br15 ptb10" v-if="item.module_id == 2" @click="handle('member/train/detail?id='+item.id)">查看</view>
					<view class="ml15 w130 bd1s brc9 c666 f26 tac br15 ptb10" v-else @click="handle('member/course/detail?id='+item.id)">查看</view>
				</view>
			</view>
		</view>
		<uv-load-more status="nomore" v-if="!more"/>
		<uv-empty v-if="!nodata"></uv-empty>
		<view class="wh80"></view>
	</view>
</template>
<script>
	let that
	export default {
		data() {
			return {
				list:[],
				page:1,
				more:true,
				nodata:true,
			}
		},
		onLoad(){
			that = this;
			that.reLoad();
		},
		onShow(){
			
		},
		onReachBottom(){
			if(that.more == false){
				return false;
			}
			that.getList();
		},
		methods: {
			reLoad() {
				// 格式化页码
				that.page = 1
				that.list = []
				that.more = true
				that.nodata = true
				// 获取产品列表
				that.getList();
			},
			getList:function(){
				let page = that.page
				that.request({
					url:'/api/course/brower',
					data:{
						page:page
					},
					load:1,
					success:function(res){
					if(res.code == 200){
						if(page == 1){
							that.list = res.data;
							if(res.data.length == 0){
								that.nodata=false;
							}
						}else{
							that.list.push(...res.data)
						}
						that.more = res.data.length < 10 ? false : true;
						that.page=page+1;
					}
				}})
			},
			Banner: function() {
				let that = this;
				that.request({
					url: '/api/index/banner',
					data: {
						type: 'courseSwiper'
					},
					success: function(res) {
						if (res.code == '200') {						
								that.swiper = res.data;
						}
					},
				});
			},
			handle:function(e){
				uni.navigateTo({
					url:"/pages/"+e,
				})
			}
		}
	}
</script>
<style lang="less" scoped>
	.item-top{height:432rpx;image{border-radius:15rpx 15rpx 0 0 ;}}
</style>
